home *** CD-ROM | disk | FTP | other *** search
- Path: atglab.bls.com!Alun.Champion
- From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
- Newsgroups: comp.lang.c
- Subject: Re: Array of pointers to a tree structure ?
- Date: 10 Jan 1996 15:22:04 GMT
- Organization: Computer People Inc.
- Distribution: world
- Message-ID: <ALUN.CHAMPION.96Jan10102204@g7240065.bridge.bst.bls.com>
- References: <4d067t$9lc@hermes.fundp.ac.be>
- <nxRvQDA1468wEw$$@harden.demon.co.uk>
- NNTP-Posting-Host: bstfirewall.bst.bls.com
- In-reply-to: Mark Harden's message of Wed, 10 Jan 1996 12:16:53 +0000
-
- In article <nxRvQDA1468wEw$$@harden.demon.co.uk> Mark Harden <mark@harden.demon.co.uk> writes:
- : In article <4d067t$9lc@hermes.fundp.ac.be>, Francisco Melo Ledermann
- : <fmelo@biq.fundp.ac.be> writes
- :> Hi Colleagues, I have been learning C language just from one month ago
- :> and I don't know too much about this language. I have a problem with the
- :> assignment of pointers in an array of pointers with a specifical defined
- :> structure. For example:
-
- :> /* BOXES STRUCTURE FOR THE CONSTRUCTION OF A TREE */
-
- :> struct boxes {
- :> int number;
- :> struct boxes *pointer_1;
- :> struct boxes *pointer_2;
- :> struct boxes *pointer_3;
- :> }
-
- :> /* ARRAY OF POINTERS TO BOXES STRUCTURE FOR MANAGE */
- :> /* SOME BRANCHES OF THE TREE */
-
- :> struct boxes array_pointers [15];
-
- : Should be "struct boxes *array_pointers [15];" otherwise you are defining
- : an array of structures.
-
- : [snip]
-
- : To set "number" in the structure pointed to by array element 3 to 13 you
- : would :-
-
- : *array_pointers [3]->number = 13;
-
- : To set "pointer_1" in the structure pointed to be array element 3 to
- : that pointed to by array element 4 you would :-
-
- : *array_pointers [3]->pointer_1 = array_pointers [4];
-
- The '*' is incorrect in these two assignments and the compiler would probably
- complain about these statements.
- The '->' operator dereferences the pointer for you.
-
- array_pointers[3]->pointer_1 = array_pointers[4];
-
- is sufficient.
-
- Regards
-
- -A.
- --
- | A.Champion |
-